package com.meslize.util.dialog;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ListAdapter;

public class Dialogs {

	public static AlertDialog getYesNoDialog(Context context, Drawable drawable, String title, String positiveButton, String negativeButton, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener negativeClick){
		return new AlertDialog.Builder(context)
        .setTitle(title)
        .setPositiveButton(positiveButton, positiveClick)
        .setNegativeButton(negativeButton, negativeClick)
        .create();
	}
	
	public static AlertDialog getDialogMessage(Context context, String title, String message, String positiveButton, String neutralButton, String negativeButton, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener neutralClick, DialogInterface.OnClickListener negativeClick){
		return new AlertDialog.Builder(context)
        .setIconAttribute(android.R.attr.alertDialogIcon)
        .setTitle(title)
        .setMessage(message)
        .setPositiveButton(positiveButton, positiveClick)
        .setNeutralButton(neutralButton, neutralClick)
        .setNegativeButton(negativeButton, negativeClick)
        .create();
	}
	
	public static AlertDialog getDialogList(Context context, String title, String[] items, DialogInterface.OnClickListener itemClick){
	    return new AlertDialog.Builder(context)
	    .setTitle(title)
	    .setItems(items, itemClick)
	    .create();
	}
	
	public static AlertDialog getDialogListCustom(Context context, String title, ListAdapter adapter, DialogInterface.OnClickListener itemClick){
	    return new AlertDialog.Builder(context)
	    .setTitle(title)
	    .setAdapter(adapter, itemClick)
	    .create();
	}
	
	public static ProgressDialog getProgressDialog(Context context, String title, int maxProgress, String positiveButton, String negativeButton, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener negativeClick){
		ProgressDialog progressDialog = new ProgressDialog(context);
		progressDialog.setIconAttribute(android.R.attr.alertDialogIcon);
		progressDialog.setTitle(title);
		progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		progressDialog.setMax(maxProgress);
		progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, positiveButton, positiveClick);
		progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, negativeButton, negativeClick);
        return progressDialog;
	}
	
	public static AlertDialog getDialogSingleChoice(Context context, String title, String[] items, int checkedItem, String positiveButton, String negativeButton, DialogInterface.OnClickListener itemClick, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener negativeClick){
		return new AlertDialog.Builder(context)
	    .setTitle(title)
	    .setSingleChoiceItems(items, checkedItem, itemClick)
	    .setPositiveButton(positiveButton, positiveClick)
	    .setNegativeButton(negativeButton, negativeClick)
	    .create();
	}
	
	public static AlertDialog getDialogSingleChoiceCustom(Context context, String title, ListAdapter adapter, int checkedItem, String positiveButton, String negativeButton, DialogInterface.OnClickListener itemClick, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener negativeClick){
		return new AlertDialog.Builder(context)
	    .setTitle(title)
	    .setSingleChoiceItems(adapter, checkedItem, itemClick)
	    .setPositiveButton(positiveButton, positiveClick)
	    .setNegativeButton(negativeButton, negativeClick)
	    .create();
	}
	
	public static AlertDialog getDialogSingleChoiceCustom(Context context, View title, ListAdapter adapter, int checkedItem, String positiveButton, String negativeButton, DialogInterface.OnClickListener itemClick, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener negativeClick){
		return new AlertDialog.Builder(context)
	    .setCustomTitle(title)
	    .setSingleChoiceItems(adapter, checkedItem, itemClick)
	    .setPositiveButton(positiveButton, positiveClick)
	    .setNegativeButton(negativeButton, negativeClick)
	    .create();
	}
	
	public static AlertDialog getDialogMultipleChoice(Context context, String title, String[] items, boolean[] values, String positiveButton, String negativeButton, DialogInterface.OnMultiChoiceClickListener itemsClick, DialogInterface.OnClickListener positiveClick, DialogInterface.OnClickListener negativeClick){
		return new AlertDialog.Builder(context)
	    .setTitle(title)
	    .setMultiChoiceItems(items, values, itemsClick)
	    .setPositiveButton(positiveButton, positiveClick)
	    .setNegativeButton(negativeButton, negativeClick)
	    .create();
	}
}
